import java.lang.reflect.Method;

/*
    通过反射获取注解对象属性
 */
public class AnnotationTest02 {

    @MyAnnotation4(name = "文梦甜" , password = "1020010530")
    public void doSome(){

    }

    public static void main(String[] args) throws Exception{
        //获取AnnotationTest02的doSome()方法上的注解信息
        Class c = Class.forName("AnnotationTest02");
        //获取doSome方法
        Method doSomeMethod = c.getDeclaredMethod("doSome");
        //判断该方法是否存在这个注解
        if (doSomeMethod.isAnnotationPresent(MyAnnotation4.class)){
            MyAnnotation4 myAnnotation4 = doSomeMethod.getAnnotation(MyAnnotation4.class);
            System.out.println(myAnnotation4.name());
            System.out.println(myAnnotation4.password());
        }
    }
}
